<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="../../../static/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../../static/js/jquery.js"></script>
  <script type="text/javascript" src="../../../static/js/getParameter.js"></script>
  <script>
    window.datas={
    }
    //获取订单信息
    function getOrderInfo(){
      let orderId = getParameter("orderid");
      $.ajax({
        url: `/marketOrders/${orderId}`,
        type: "get",
        dataType: "json",
        success:(data)=>{
          let orderInfo=data.data;
          $(".orderid").text(orderInfo.orderid);
          $(".customName").text(orderInfo.customName);
          $(".customName").attr("href",`../../market/customer/customerView?customid=${orderInfo.customid}`)
          $(".telephone").text(orderInfo.telephone);
          $(".ordertime").text(orderInfo.ordertime);
          $(".operatorName").text(orderInfo.operatorName);
          $(".ordermoney").text(orderInfo.ordermoney);
          orderInfo.orderdetails.forEach((item,index)=>{
            $("#detailInfo").append(`<tr>
          <td>${index+1}</td>
          <td>${item.brandName}</td>
          <td>${item.typeName}</td>
          <td>${item.productModel}</td>
          <td>${item.purchaseNum}</td>
          <td>${item.productUnit}</td>
          <td>${item.productprice}</td>
          <td>${item.prototal}</td>
        </tr>`);
          })
        }
      })
    }
    //获取审核信息
    function getExamineInfo(){
      datas.ExamineInfo={
        opinion:$(".option").val(),
        status:$(".status option:selected").val(),
        orderid:$(".orderid").text(),
        checkid:JSON.parse(localStorage.getItem("user")).uid,
      }
    }
    //提交审核
    function submitExamine(){
      getExamineInfo();
     $.ajax({
       url: "/orderExamine",
       type: "put",
       dataType: "json",
       contentType: "application/json;charset=utf8",
       data: JSON.stringify(datas.ExamineInfo),
       success:(data)=>{
         if(data.status==200){
           alert("提交成功");
           window.location.href="/market/orderExamine/findPageAll"
         }
       }
     })

    }
    $(()=>{
      getOrderInfo();
    })


  </script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>营销管理</li>
    <li>订购单审核管理</li>
    <li>审核</li>
  </ul>
</div>
<div class="formbody">
  <div class="formtitle"><span>订购单审核</span></div>
  <ul class="forminfo">
    <li>
      <label>订单编号</label>
      <cite class="orderid"></cite>
    </li>
    <li>
      <label>客户姓名</label>
      <cite><a  title="点击查看客户详细信息" class="tablelink customName"></a></cite>
    </li>
    <li>
      <label>联系电话</label>
      <cite class="telephone"></cite>
    </li>
    <li>
      <label>订购时间</label>
      <cite class="ordertime"></cite>
    </li>
    <li>
      <label>总金额</label>
       <cite class="ordermoney"></cite>
    </li>
    <li>
      <label>操作人</label>
      <cite class="operatorName"></cite>
    </li>
  </ul>
  <table class="tablelist">
      <thead>
        <tr>
          <th>序号</th>
          <th>品牌</th>
          <th>类型</th>
          <th>型号</th>
          <th>数量</th>
          <th>单位</th>
          <th>单价</th>
          <th>金额</th>
        </tr>
      </thead>
      <tbody id="detailInfo">
      </tbody>
  </table>
  <ul class="forminfo">
    <li>
      <label>审核意见</label>
      <textarea class="textinput option"></textarea>
    </li>
    <li>
      <label>审核状态</label>
      <select class="dfselect status">
          <option>请选择</option>
          <option value="3">通过</option>
          <option value="4">不通过</option>
      </select>
    </li>
    <li>
      <label>&nbsp;</label>
      <input name="" type="button" class="btn" onclick="submitExamine()" value="审核"/>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <input name="" type="button" class="btn" value="返回" onclick="window.location.href='findPageAll'"/>
    </li>
  </ul>
<script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
</script>
</body>
</html>
